package com.twu.biblioteca;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * User: Demon
 * Date: 13-6-27
 * Time: 上午7:03
 * To change this template use File | Settings | File Templates.
 */
public class UserLogin {

    UserLogin(){
        str="";
        profession="";
        level=0;
    }
    public void UserInput() {
        Scanner content =new Scanner(System.in);
        str=content.next();
    }
    public String GetUserInput() {
        return str;
    }

    public void SetProfession(String input) {
        profession=input;
    }

    public void SetLevel(){
        if(profession=="membership") level=1;
        if(profession=="manager") level=2;
    }

    public int GetUserLevel() {
        return level;
    }

    public void ShowWelcome() {
        System.out.println("Welcome to The Bangalore Public Library," + profession+"!");
    }

    public void Login(){
        System.out.println("please input your profession:(manager/membership/students)");
        UserInput();
        SetProfession(GetUserInput());
        ShowWelcome();
    }

    private String str;
    private String profession;
    private int level;
    private String reserve_book_name;
    private String[] reserve_book_list=new String[10]; //everyone only reserve 10 books
    BookList all_book_list=new BookList();//

    public void SetReserveBookName(String input) {
         reserve_book_name=input;
    }

    public int UpdateReserveBookList() {
        if(all_book_list.CheckReserveBookIsLegal(reserve_book_name)&&CheckReserveBookIsNotExist()){
            //reserve_book_list[reserve_book_list.length]=reserve_book_name;
            System.out.println("Thank You! Enjoy the book!");
            return 1;
        }
        else return 0;
    }

    public boolean CheckReserveBookIsNotExist(){
        for(int i=0;i<reserve_book_list.length;i++){
            if(reserve_book_name==reserve_book_list[i]){
                System.out.println("The book exists already!Thank You! Enjoy the book!");
                return false;
            }
        }
        return true;
    }

    public void ReserveBook(){
        System.out.println("Now,you could choose the book you want to reserve.Please input the book you want to reserve:");
        UserInput();
        //System.out.print(GetUserInput());
        //String str1=GetUserInput();
        SetReserveBookName(GetUserInput());
        //System.out.print(reserve_book_name);
        UpdateReserveBookList();
    }
}
